package com.mx.test;

import static org.junit.Assert.*;

import java.sql.SQLException;

import javax.sql.DataSource;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.mx.entity.Person;

public class test {
  ApplicationContext  ctx=null;
	
	@Test
  public  void  testapp() throws SQLException{
	  ctx=new ClassPathXmlApplicationContext("applicationContext.xml");
	  //测试数据库
	  //DataSource  source=ctx.getBean(DataSource.class);
	  //System.out.println(source.getConnection().toString());
	 // System.out.println(ctx);
	  Session  session=ctx.getBean(SessionFactory.class).openSession();
	  Transaction  tx=session.beginTransaction();
	  Person  person=new  Person("毛雄","aaa","mx");
	  
	  session.save(person);
	  tx.commit();
	  session.close();
  }
	
}
